home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0193_Extracting ICONS from DLL.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-11-29  |  688 b   |  27 lines

  1. unit ExtrIcon;
  2.  
  3. interface
  4. uses ShellAPI, Graphics, WinTypes, SysUtils;
  5.  
  6. function ExtractIconFromFile(FileName: string; Index: integer): HIcon;
  7.  
  8. implementation
  9.  
  10. function ExtractIconFromFile(FileName: string; Index: integer): HIcon;
  11. var
  12.   Buff: array [0..255] of char;
  13.   iNumberOfIcons: integer;
  14. begin
  15.   { If we have a valid file. }
  16.   if FileExists(FileName) then
  17.      begin
  18.      { Find out how many icons are in the file }
  19.      iNumberOfIcons := ExtractIcon(hInstance, StrPCopy(Buff, FileName), Cardinal(-1));
  20.      if (Index > 0) and (Index < iNumberOfIcons) and (iNumberOfIcons > 0) then
  21.      Result:= ExtractIcon(hInstance, Buff, Index);
  22.      end;
  23.  
  24. end;
  25.  
  26. end.
  27.